package thread;

public class TakeMonet {
	
	static BankAcount ba = new BankAcount(10000);
	
	public static void main(String args[]) {
		
		//take
		new Thread(new Runnable() {

			public void run() {
				for (int i = 0; i < 1000000; i++) {
//					synchronized(ba) {
//						ba.addMoney(1);
//					}
					ba.addMoney(1);
					
				}
				System.out.println("AfterPut: " + ba.getMoney());
			}
			
		}).start();
		
		
		//put
		new Thread(new Runnable() {

			public void run() {
				for (int i = 0; i < 1000000; i++) {
//					synchronized(ba) {
//						
//					}
					ba.subMoney(1);
				}
				System.out.println("AfterTake: " + ba.getMoney());
			}
			
		}).start();
	}
	
}
